package gui.bottombar;

import javax.swing.JPanel;
import javax.swing.border.LineBorder;
import java.awt.Color;
import java.awt.Dimension;
import javax.swing.JLabel;
import java.awt.Font;
import java.awt.BorderLayout;
import javax.swing.ImageIcon;
import javax.swing.JSeparator;
import javax.swing.SwingConstants;

public class BottomBar extends JPanel {

	/**
	 * The JLable component on the left side of the bottom bar is used to display
	 * the message for important notice that programmer wants users to know, such
	 * as system just saved your NLP results, or "welcome" information.  
	 * */
	private JLabel label_message = null;
	
	
	/**
	 * Create the panel.
	 */
	public BottomBar() {
		
		//setBorder(new LineBorder(new Color(220, 220, 220), 1, true));		
		setPreferredSize( new Dimension(532, 20) );
		setBackground( new Color(232,232,232));
		setLayout(new BorderLayout(0, 0));
		
		// the message label on the bottom left
		label_message = new JLabel("Welcome to EATEP NLP System!");
		label_message.setFont(new Font("Calibri", Font.PLAIN, 12));		
		add(label_message);
		
		// the panel on the right side of the bottom bar. It's used as an container 
		// to hold the separator and the user label
		JPanel panel_rightside = new JPanel();
		panel_rightside.setBorder(null);
		panel_rightside.setBackground( new Color(232,232,232));
		add(panel_rightside, BorderLayout.EAST);
		panel_rightside.setLayout(new BorderLayout(0, 0));
		
		// separator
		JSeparator separator = new JSeparator();
		separator.setOrientation(SwingConstants.VERTICAL);
		panel_rightside.add(separator, BorderLayout.WEST);
		
		// user label: the user icon and the name of current user
		JLabel lblAnonymous = new JLabel("anonymous");
		lblAnonymous.setFont(new Font("Calibri", Font.PLAIN, 12));
		lblAnonymous.setIcon(new ImageIcon(BottomBar.class.getResource("/res/user.jpg")));
		panel_rightside.add(lblAnonymous, BorderLayout.CENTER);
	}
	
	
	/**
	 * Display the given message on the left of the bottom bar; this message usually
	 * is a important system message or welcome message.
	 * 
	 * @param	msg	The message programmer wants to display on the left of the 
	 * bottom bar. 
	 * 
	 * */
	public void setMessage(String msg){
		
		if(( msg == null )||(msg.trim().length()<1))
			return;
		
		String text = msg.trim();		
		label_message.setText(text);
	}
}
